namespace YXShop.ExcelLite
{
    using System;

    internal abstract class FormulaToken
    {
        private int size;
        private FormulaTokenCode token;
        private FormulaTokenTypeEx type;

        public FormulaToken(FormulaTokenCode code, int size) : this(code, size, FormulaTokenType.Empty)
        {
        }

        public FormulaToken(FormulaTokenCode code, int size, FormulaTokenType type)
        {
            this.token = code;
            this.size = size;
            this.type = new FormulaTokenTypeEx(type);
        }

        public virtual byte[] ConvertToBytes()
        {
            byte[] buffer = new byte[this.Size];
            buffer[0] = (byte) this.Token;
            return buffer;
        }

        public virtual void DelayInitialize(object[] data)
        {
        }

        public virtual void Read(byte[] rpnBytes, int startIndex)
        {
        }

        public override string ToString()
        {
            return string.Empty;
        }

        public byte Code
        {
            get
            {
                return (byte) this.Token;
            }
        }

        public virtual int Size
        {
            get
            {
                return this.size;
            }
        }

        protected FormulaTokenCode Token
        {
            get
            {
                return this.token;
            }
        }

        public FormulaTokenTypeEx Type
        {
            get
            {
                return this.type;
            }
        }
    }
}

